#coding=utf-8
#import libs 
import sys
import add_device_cmd
import add_device_sty
import Fun
import os
import tkinter
from   tkinter import *
import tkinter.ttk
import tkinter.font
#Add your Varial Here: (Keep This Line of comments)
#Define UI Class
class  add_device:
    def __init__(self,root,isTKroot = True):
        uiName = self.__class__.__name__
        Fun.Register(uiName,'UIClass',self)
        self.root = root
        Fun.Register(uiName,'root',root)
        style = add_device_sty.SetupStyle()
        if isTKroot == True:
            root.title("添加设备")
            root.resizable(False,False)
            if os.path.exists("/logo.ico"):
                root.iconbitmap("G:/work/work/lims/devices_python/Ico/logo.ico")
            Fun.CenterDlg(uiName,root,259,308)
            root['background'] = '#efefef'
        Form_1= tkinter.Canvas(root,width = 10,height = 4)
        Form_1.place(x = 0,y = 0,width = 259,height = 308)
        Form_1.configure(bg = "#efefef")
        Form_1.configure(highlightthickness = 0)
        Fun.Register(uiName,'Form_1',Form_1)
        #Create the elements of root 
        ComboBox_3_Variable = Fun.AddTKVariable(uiName,'ComboBox_3')
        ComboBox_3 = tkinter.ttk.Combobox(Form_1,textvariable=ComboBox_3_Variable, state="readonly")
        Fun.Register(uiName,'ComboBox_3',ComboBox_3,'device_type')
        ComboBox_3.place(x = 97,y = 18,width = 137,height = 20)
        ComboBox_3.configure(state = "readonly")
        ComboBox_3["values"]=['梅特勒-天平']
        ComboBox_3.current(0)
        Label_4 = tkinter.Label(Form_1,text="波 特 率：",width = 10,height = 4)
        Fun.Register(uiName,'Label_4',Label_4)
        Label_4.place(x = 1,y = 109,width = 100,height = 20)
        Label_4.configure(relief = "flat")
        ComboBox_5_Variable = Fun.AddTKVariable(uiName,'ComboBox_5')
        ComboBox_5 = tkinter.ttk.Combobox(Form_1,textvariable=ComboBox_5_Variable, state="readonly")
        Fun.Register(uiName,'ComboBox_5',ComboBox_5,'device_serial_bps')
        ComboBox_5.place(x = 97,y = 109,width = 137,height = 20)
        ComboBox_5.configure(state = "readonly")
        ComboBox_5["values"]=['9600','19200','38400','57600','115200']
        ComboBox_5.current(0)
        Label_6 = tkinter.Label(Form_1,text="设备名称：",width = 10,height = 4)
        Fun.Register(uiName,'Label_6',Label_6)
        Label_6.place(x = 1,y = 47,width = 100,height = 20)
        Label_6.configure(relief = "flat")
        Text_7 = tkinter.Text(Form_1)
        Fun.Register(uiName,'Text_7',Text_7,'device_name')
        Text_7.place(x = 97,y = 45,width = 137,height = 22)
        Text_7.configure(relief = "sunken")
        Label_8 = tkinter.Label(Form_1,text="串      口：",width = 10,height = 4)
        Fun.Register(uiName,'Label_8',Label_8)
        Label_8.place(x = 1,y = 73,width = 100,height = 20)
        Label_8.configure(relief = "flat")
        ComboBox_9_Variable = Fun.AddTKVariable(uiName,'ComboBox_9')
        ComboBox_9 = tkinter.ttk.Combobox(Form_1,textvariable=ComboBox_9_Variable, state="readonly")
        Fun.Register(uiName,'ComboBox_9',ComboBox_9,'device_serial_port')
        ComboBox_9.place(x = 95,y = 76,width = 139,height = 20)
        ComboBox_9.configure(state = "readonly")
        Label_10 = tkinter.Label(Form_1,text="备注说明：",width = 10,height = 4)
        Fun.Register(uiName,'Label_10',Label_10)
        Label_10.place(x = 1,y = 143,width = 100,height = 20)
        Label_10.configure(relief = "flat")
        Text_11 = tkinter.Text(Form_1)
        Fun.Register(uiName,'Text_11',Text_11,'device_remark')
        Text_11.place(x = 97,y = 146,width = 137,height = 115)
        Text_11.configure(relief = "sunken")
        Label_2 = tkinter.Label(Form_1,text="设备类型：",width = 10,height = 4)
        Fun.Register(uiName,'Label_2',Label_2)
        Label_2.place(x = 1,y = 18,width = 100,height = 20)
        Label_2.configure(relief = "flat")
        Button_12 = tkinter.Button(Form_1,text="添  加",width = 10,height = 4)
        Fun.Register(uiName,'Button_12',Button_12)
        Button_12.place(x = 89,y = 272,width = 100,height = 28)
        Button_12.configure(command=lambda:add_device_cmd.Button_12_onCommand(uiName,"Button_12"))
        #Inital all element's Data 
        Fun.InitElementData(uiName)
        add_device_cmd.Form_1_onLoad(uiName)
        #Add Some Logic Code Here: (Keep This Line of comments)


#Create the root of Kinter 
if  __name__ == '__main__':
    root = tkinter.Tk()
    MyDlg = add_device(root)
    root.mainloop()
